package springstudy.annotation;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import springstudy.configuration.HelloWorldConfiguration;

/**
 * @Author acy
 * @Date 2019/04/24
 */
public class HelloWorldImportRegisterSelector implements ImportBeanDefinitionRegistrar {
	@Override
	public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
		//构建AbstractBeanDefinition
		AbstractBeanDefinition HelloWorldBeanDefinition = BeanDefinitionBuilder.rootBeanDefinition(HelloWorldConfiguration.class).getBeanDefinition();
		//注册HelloWorldBeanDefinition的时候也会注册string类型的helloWorld名称的bean
		beanDefinitionRegistry.registerBeanDefinition("helloWorldConfiguration",HelloWorldBeanDefinition);
	}
}
